package com.exonline.commons.utils;
/**
 * @desc    json工具类
 * @author  hbrj
 */
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtils {
    /**
     * @desc  1.将对象转换为json字符串
     * @param obj 要转换的对象
     * @return 转完之后的json字符串
     * @throws JsonProcessingException 如果转换失败,抛出该异常
     */
    public static String toJson(Object obj) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr = mapper.writeValueAsString(obj);
        System.out.println("jsonUtils>>>" + jsonStr);
        return jsonStr;
    }
}
